package com.mega.fe.fuck;

import com.mega.fe.mixins.EntityRenderDispatcherAccessor;
import com.mega.fe.util.BaseInit;
import com.mega.fe.util.MEGA;
import com.mega.fe.util.client.MegaFont;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Options;
import net.minecraft.client.gui.Font;
import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;

public class FuckEntityRenderDispatcher extends EntityRenderDispatcher {
    public static EntityRenderer<Entity> NULL =
            new EntityRenderer<>(
                    new FuckRenderContext(
                            Minecraft.getInstance().entityRenderDispatcher,
                            Minecraft.getInstance().getItemRenderer(),
                            Minecraft.getInstance().blockRenderer,
                            Minecraft.getInstance().entityRenderDispatcher.getItemInHandRenderer(),
                            Minecraft.getInstance().getResourceManager(),
                            ((EntityRenderDispatcherAccessor)Minecraft.getInstance().entityRenderDispatcher).entityModels(),
                            MegaFont.FantasyFont)) {
                @Override
                public ResourceLocation getTextureLocation(Entity p_114482_) {
                    return null;
                }

                @Override
                protected void renderNameTag(Entity p_114498_, Component p_114499_, PoseStack p_114500_, MultiBufferSource p_114501_, int p_114502_) {
                }

                @Override
                public void render(Entity p_114485_, float p_114486_, float p_114487_, PoseStack p_114488_, MultiBufferSource p_114489_, int p_114490_) {
                }

                @Override
                public boolean shouldRender(Entity p_114491_, Frustum p_114492_, double p_114493_, double p_114494_, double p_114495_) {
                    return false;
                }

                @Override
                public Vec3 getRenderOffset(Entity p_114483_, float p_114484_) {
                    return Vec3.ZERO;
                }

                @Override
                protected boolean shouldShowName(Entity p_114504_) {
                    return false;
                }

                @Override
                protected int getBlockLightLevel(Entity p_114496_, BlockPos p_114497_) {
                    return 0;
                }

                @Override
                protected int getSkyLightLevel(Entity p_114509_, BlockPos p_114510_) {
                    return 0;
                }

                @Override
                public Font getFont() {
                    return MegaFont.FantasyFont;
                }
            };
    public static int klass_ptr;

    static {
        try {
            klass_ptr = MEGA.KLASS_PTR(FuckEntityRenderDispatcher.class);
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }

    public FuckEntityRenderDispatcher(Minecraft p_234579_, TextureManager p_234580_, ItemRenderer p_234581_, BlockRenderDispatcher p_234582_, Font p_234583_, Options p_234584_, EntityModelSet p_234585_) {
        super(p_234579_, p_234580_, p_234581_, p_234582_, p_234583_, p_234584_, p_234585_);
    }

    @Override
    public <T extends Entity> EntityRenderer<? super T> getRenderer(T p_114383_) {
        if (BaseInit.isDeath(p_114383_) || p_114383_ == null)
            return NULL;
        return super.getRenderer(p_114383_);
    }
}
